package com.nuoniu.sibanyun.controller.cms;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nuoniu.sibanyun.common.BaseController;
import com.nuoniu.sibanyun.common.result.HttpResult;
import com.nuoniu.sibanyun.entity.cms.CmsColumn;
import com.nuoniu.sibanyun.service.cms.ICmsColumnService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 网站栏目 前端控制器
 * </p>
 *
 * @author 小啊刚
 * @since 2021-08-10
 */
@RestController
@RequestMapping("/cms/column")
@Api(tags = "网站栏目管理")
public class CmsColumnController extends BaseController {

    @Autowired
    private ICmsColumnService cmsColumnService;

    @ApiOperation("获取列表")
    @GetMapping("pageList")
    public HttpResult pageList(Page page, CmsColumn column) {
        return HttpResult.ok(cmsColumnService.pageList(page, column));
    }


    @ApiOperation("保存栏目")
    @PostMapping("save")
    public HttpResult save(@RequestBody CmsColumn column) {
        cmsColumnService.saveColumn(column);
        return HttpResult.ok();
    }

    @ApiOperation("删除栏目")
    @DeleteMapping("delete")
    public HttpResult delete(Long id) {
        cmsColumnService.deleteById(id);
        return HttpResult.ok();
    }
}
